<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>vue-resource</title>
  <script src="./vue.js"></script>
  <!-- 依赖于vue.js -->
  <script src="./vue-resource.js"></script>
</head>
<body>
  <div id="app">
    <button @click="getInfo">get请求</button>
    <button @click="postInfo">post请求</button>
    <button @click="jsonpInfo">jsonp请求</button>

  </div>

</body>
<script>
var vm = new Vue({
  el: "#app",
  data: {},
  methods: {
   getInfo() {
    this.$http.get("http://jsonplaceholder.typicode.com/users").then(response => {
      // success callback
      console.log(response.body);
    },response => {
      // error callback
      console.log(response);
    });
   },
   postInfo() {
     this.$http.post("http://jsonplaceholder.typicode.com/users").then(response => {
      // success callback
      console.log(response);
    })
   },
   jsonpInfo() {
     // jsonp能
     this.$http.jsonp("http://jsonplaceholder.typicode.com/users").then(response => {
      // success callback
      console.log(response.body);
    },response => {
      // error callback
      console.log(response);
    });
   } 
  }
})
</script>
</html>